﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.Messages;

namespace PMS.Data.EntityMap.Messages
{
    /// <summary>
    /// Represents a emailaccount mapping configuration
    /// </summary>
    public partial class EmailAccountMap : PMSEntityTypeConfiguration<EmailAccount>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<EmailAccount> builder)
        {
            builder.ToTable("msg_emailaccount");
            builder.HasKey(email => email.Id);

            builder.Property(email => email.Email).HasMaxLength(200).IsRequired();
            builder.Property(email => email.ReplyTo).HasMaxLength(200).IsRequired();
            builder.Property(email => email.DisplayName).HasMaxLength(200);
            builder.Property(email => email.Host).HasMaxLength(128).IsRequired();
            builder.Property(email => email.Port).IsRequired();
            builder.Property(email => email.Username).HasMaxLength(200).IsRequired();
            builder.Property(email => email.Password).HasMaxLength(200).IsRequired();

            builder.Ignore(email => email.IsActive);
            builder.Ignore(email => email.CreatedOnTimeUtc);
            builder.Ignore(email => email.UpdatedOnTimeUtc);
            base.Configure(builder);
        }

        #endregion
    }
}
